package acwing;

import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Objects;
import java.util.Scanner;

public class ac1209 {
    static final int N = 10;
    static int n, ans;
    static boolean[] st = new boolean[N];
    static boolean[] backup = new boolean[N];
    static StreamTokenizer cin = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

    static int nextInt() throws IOException {
        cin.nextToken();
        return (int) cin.nval;
    }

    static boolean check(int a, int c) {
        int b = c * (n - a);
        if (a <= 0 || b <= 0 || c <= 0) return false ;
//        backup = Arrays.copyOf(st, st.length);
//        backup = st.clone();
//        System.arraycopy(st, 0, backup, 0, st.length);
//        boolean[] backup = new boolean[st.length];    
        backup = st.clone();
        while (b != 0) {
            int x =  b % 10;
            b /= 10;
            if (x == 0 || backup[x]) return false;
            backup[x] = true;
        }
        for (int i = 1; i <= 9; i ++ ) {
            if (!backup[i]) return false;
        }
        return true;
    }

    static void dfs_c(int u, int a, int c) {
        if (u > 9) return ;
        if (check(a, c)) ans ++ ;
        for (int i = 1; i <= 9; i ++ ) {
            if (!st[i]) {
                st[i] = true;
                dfs_c(u+1, a, c*10+i);
                st[i] = false;
            }
        }
    }

    static void dfs_a(int u, int a) {
        if (a >= n || u > 9) return ;
        if (a > 0) dfs_c(u, a, 0);
        for (int i = 1; i <= 9; i ++ ) {
            if (!st[i]) {
                st[i] = true;
                dfs_a(u+1, a*10+i);
                st[i] = false;
            }
        }
    }

    public static void main(String[] args) throws IOException {
//        Scanner sc = new Scanner(System.in);
        n = nextInt();
//        n = sc.nextInt();
        dfs_a(0, 0);
        out.println(ans);
//        out.println(n);
        out.close();
    }
}